﻿// 版权所有：
// 文 件 名：PM.cs
// 功能描述：公共变量
// 创建标识：Seven Song(m.sh.lin0328@163.com) 2014/1/19 12:08:42
// 修改描述：
//----------------------------------------------------------------*/
using System;
using System.Collections;
using System.Text;
using TimedTask.Enums;

namespace TimedTask.Models
{
    /// <summary>
    /// 全局变量
    /// </summary>
    public class Const
    {
        public const string ApplicationName = "TimedTask";//应用程序英文名
        public static char SpiderChar = '⊙';//字符串特殊分割符

        private static Hashtable _audios;
        private static Hashtable _taskTypes = new Hashtable();
        private static Hashtable _FileSuffix = new Hashtable();

        /// <summary>
        /// 天气预报接口地址
        /// </summary>
        public static string WeatherUrl = "http://t.weather.sojson.com/api/weather/city/";
        /// <summary>
        /// 天气预报 - 5天详情
        /// </summary>
        //public static string WeatherInfo { set; get; }
        /// <summary>
        /// 天气预报详细接口地址
        /// </summary>
        //public static string WeatherDetailUrl = "http://m.weather.com.cn/data/{0}.html";
        /// <summary>
        /// 个人主页
        /// </summary>
        public static string HomePageUrl = "http://www.cnblogs.com/shanlin/";
        /// <summary>
        /// 是否检查任务列表（更改任务下次启动时间）
        /// </summary>
        public static bool IsCheckTask { get; set; }
        /// <summary>
        /// 锁屏背景
        /// </summary>
        public static string LockBgImg { set; get; }
        /// <summary>
        /// 是否记录运行日志
        /// </summary>
        public static bool SaveLog { set; get; }
        /// <summary>
        /// 资讯列表抓取页面
        /// </summary>
        //public static string NewsUrl { set; get; }
        /// <summary>
        /// 资讯列表页面标签
        /// </summary>
        //public static SortedList NewsTag { set; get; }
        /// <summary>
        /// 天气预报选择城市编码
        /// </summary>
        public static string CityCode { set; get; }
        public static string CityName { set; get; }
        /// <summary>
        /// 锁屏时间 分钟
        /// </summary>
        public static int LockMinute { get; set; }
        /// <summary>
        /// 窗体背景
        /// </summary>
        public static string AppBgImg { get; set; }
        /// <summary>
        /// 是否最小化到托盘
        /// </summary>
        public static bool MinToTray { get; set; }
        /// <summary>
        /// 是否启动后自动弹出资讯
        /// </summary>
        //public static bool ShowNews { get; set; }
        /// <summary>
        /// 是否开启关机提醒事项
        /// </summary>
        public static bool ShowShutDownRemind { get; set; }
        /// <summary>
        /// 关机提醒内容
        /// </summary>
        public static String ShutDownContent { get; set; }

        /// <summary>
        /// 文件后缀
        /// </summary>
        public static Hashtable FileSuffix
        {
            get
            {
                if (_FileSuffix == null || _FileSuffix.Count == 0)
                {
                    _FileSuffix.Add(FileType.RAR, "rar|zip|7z");
                    _FileSuffix.Add(FileType.TXT, "txt");
                    _FileSuffix.Add(FileType.DOC, "doc|docx|xls|xlsx|ppt|pptx|pdf");
                    _FileSuffix.Add(FileType.IMAGE, "jpg|jpeg|png|gif|bmp|pcx");
                    _FileSuffix.Add(FileType.VIDEO, "avi|mov|wmv|3gp|3gp|flv|mpeg");
                    _FileSuffix.Add(FileType.AUDIO, "mp3|wma|midi");
                    _FileSuffix.Add(FileType.CUSTOM, "");
                }
                return _FileSuffix;
            }
        }
        /// <summary>
        /// 任务类型
        /// </summary>
        public static Hashtable TaskTypes
        {
            get
            {
                if (_taskTypes == null || _taskTypes.Count == 0)
                {
                    _taskTypes.Add("0", "定时任务");
                    _taskTypes.Add("1", "定时提醒");
                    _taskTypes.Add("2", "定时关机");
                    _taskTypes.Add("3", "关闭显示器");
                    _taskTypes.Add("4", "打开显示器");
                    _taskTypes.Add("5", "定时锁屏");
                }
                return _taskTypes;
            }
        }
        /// <summary>
        /// 可执行文件启动目录
        /// </summary>
        public static string StartPath { get; set; }
        /// <summary>
        /// 计划任务配置文件路径
        /// </summary>
        public static string TaskConfig { get; set; }
        /// <summary>
        /// 是否已经锁屏
        /// </summary>
        public static bool IsScreenLock { get; set; }
        /// <summary>
        /// 配置文件路径
        /// </summary>
        public static string Config { get; set; }
        /// <summary>
        /// 声音列表
        /// </summary>
        public static Hashtable Audios
        {
            get
            {
                if (_audios == null || _audios.Count == 0)
                {
                    string path = StartPath + "\\Audio\\";
                    if (System.IO.Directory.Exists(path))
                    {
                        string name = "";
                        _audios = new Hashtable();
                        foreach (string f in System.IO.Directory.GetFileSystemEntries(path))
                        {
                            path = System.IO.Path.GetFullPath(f);
                            name = System.IO.Path.GetFileName(f);
                            name = name.Substring(0, name.LastIndexOf("."));

                            if (!_audios.ContainsKey(name))
                            {
                                _audios.Add(name, path);
                            }
                        }
                    }
                }
                return _audios;
            }
        }
        /// <summary>
        /// 记事类别
        /// </summary>
        public static Hashtable NoteTypes { set; get; }
    }
}
